import { BaseHintIcon } from "./BaseHintIcon";
import { ImagesConst } from "../../../resource/ImagesConst";
import { SecTimerView } from "../SecTimerView";
import { StyleConst } from "../../../../component/gconst/StyleConst";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { Language } from "../../../../../extend/language/Language";
import { Alert } from "../../../../../com/mui/controls/Alert";
import { GameProxy } from "../../../mvc/GameProxy";
import { ViewEvent } from "../../../../mvc/events/ViewEvent";
import { EffectManager } from "../../../manager/EffectManager";
import { Global } from "../../../../../com/gengine/global/Global";
type int = number;
//class TurnedHintIcon
    
    export  class TurnedHintIcon extends BaseHintIcon
    {
        constructor()
        {
            super(ImagesConst.FW_Huan);
            return;
        }

        protected /* override */ createChindren(): void
        {
            super.createChindren();
            _hintIcon.x = (-_hintIcon.width) / 2;
            this._leftTimeView = new SecTimerView();
            this._leftTimeView.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._leftTimeView.mouseEnabled = false;
            this._leftTimeView.defaultTextFormat = StyleConst.textFormatA;
            this._leftTimeView.filters = [FilterConst.glowFilter];
            this._leftTimeView.setParse(Language.getString(50068));
            this._leftTimeView.width = 300;
            this._leftTimeView.y = _hintIcon.height;
            this._leftTimeView.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this.addChild(this._leftTimeView);
            return;
        }

        public updateLeftTime(arg1: int): void
        {
            this._leftTimeView.setLeftTime(arg1);
            return;
        }

        protected /* override */ onHintIconClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Alert.show(Language.getString(40096), null, Alert.YES | Alert.NO, null, this.onCloseHandler);
            return;
        }

        /* internal  */onCloseHandler(arg1: int): void
        {
            if (arg1 == Alert.YES) 
            {
                GameProxy.roleProxy.endModelChange();
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            if (_layer) 
            {
                _isHide = false;
                _layer.addPopUp(this);
                dispatchEvent(new ViewEvent(ViewEvent.Show));
                if (!(arg1 == 0) && !(arg2 == 0)) 
                {
                    _layer.setPosition(this, arg1, arg2);
                }
            }
            if (this.parent) 
            {
                EffectManager.glowFilterReg(_hintIcon, [FilterConst.hintIconFilter]);
            }
            return;
        }

        public /* override */ hide(): void
        {
            if (_layer) 
            {
                _isHide = true;
                dispatchEvent(new ViewEvent(ViewEvent.Hide));
                _layer.removePopup(this);
            }
            if (this.parent == null) 
            {
                EffectManager.glowFilterUnReg(_hintIcon);
            }
            return;
        }

        public /* override */ resize(arg1: number=0, arg2: number=0): void
        {
            if (arg1 == 0 || arg2 == 0) 
            {
                arg1 = Global.stage.stageWidth;
                arg2 = Global.stage.stageHeight;
            }
            this.x = arg1 - _hintIcon.width / 2 - 25;
            this.y = arg2 - _hintIcon.height - 50;
            return;
        }

        /* internal */ /* var */_leftTimeView: SecTimerView;

        /* internal */ /* var */_textFiled: Object /* flash.text.TextField */;
    }
